package com.hospital.schedule.module.tasks;

import com.hospital.schedule.module.service.ITDoctorAttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

// 1. 开启定时任务功能（加在配置类或启动类上）
@EnableScheduling
@Component // 注入Spring容器
public class AttendAnceTask {
    // 2. 定义定时任务：每天凌晨2点执行
    @Autowired
    private ITDoctorAttendanceService tDoctorAttendanceService;
    @Scheduled(cron = "0 0 23 * * ?")
//    @Scheduled(cron = "0 * * * * ?")
    public void dailyBackup() {
        System.out.println("执行每日数据备份：" + LocalDateTime.now());
        // 具体业务逻辑：备份数据库、清理日志等
        tDoctorAttendanceService.inspectAttendance();
    }
}
